package com.sina.medical.web;


import com.sina.medical.core.enmu.ResultCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.MessageSource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.core.env.Environment;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 *
 */
public class BaseController implements InitializingBean {

    public static final String STATUS = "status";

    public static final String CODE = "code";

    public static final String MSG = "msg";

    public static final String DATA = "data";

    public static final ResultCode OK = ResultCode.ok;

    public static final String RESULT = "result";

    public static final String X_SIGNATURE =  "x-signature";

    public static final String X_APP_KEY = "x-appKey";

    public static final String XX_API_VERSION = "xx-apiVersion";

    public static final String XX_KEY_VERSION = "xx-key-version";


    public static final String CONTENT_TYPE_JSON_UTF8 = "Content-Type=application/json;charset=UTF-8";

    public static final String ROW_COUNT = "rowCount";

    public static final String PAGE = "page";

    protected static final String LOCAL_PROFILE = "local";

    public static final String DEFAULT_SIGNATURE_VIEW = "signature/result";

    protected final Logger LOG = LoggerFactory.getLogger(this.getClass());




    @Autowired
    protected Environment environment;

    protected Set<String> activeProfiles;


    @Override
    public void afterPropertiesSet() throws Exception {

    }

    private void initActiveProfiles(){
        activeProfiles = new HashSet<>(
                Arrays.asList(environment.getActiveProfiles())
        );
    }

}
